package com.yalemang.androidclassroom

import android.app.Activity
import android.app.Application
import android.os.Bundle
import android.util.ArrayMap
import androidx.fragment.app.FragmentActivity

class App:Application() {

    override fun onCreate() {
        super.onCreate()

        //全局监听Activity生命周期调用
        registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks{
            override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
                //监听所有Fragment的生命周期，那当然可以监听所有fragment的onDestroy
                val fragmentActivity = activity as FragmentActivity
                //fragmentActivity.supportFragmentManager.registerFragmentLifecycleCallbacks()
            }

            override fun onActivityStarted(activity: Activity) {

            }

            override fun onActivityResumed(activity: Activity) {

            }

            override fun onActivityPaused(activity: Activity) {

            }

            override fun onActivityStopped(activity: Activity) {

            }

            override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {

            }

            override fun onActivityDestroyed(activity: Activity) {
               //LeakCanary监听泄漏的起点
            }
        })
    }

}